﻿using System;

namespace IGMVC.Web.Models
{
    public class IssueTypeRepository : FakeRepository<IssueType>
    {
        public override void Insert(IssueType item)
        {
            if (string.IsNullOrEmpty(item.ImageUrl))
            {
                item.ImageUrl = "images/noimage.png";
            }
            base.Insert(item);
        }

        public override void Update(IssueType item)
        {
            if (string.IsNullOrEmpty(item.ImageUrl))
            {
                item.ImageUrl = this.GetById(item.Id).ImageUrl;
            }
            base.Update(item);
        }

        public void AddFakeData()
        {
            if (!this.HasItems)
            {
                this.Insert(new IssueType() { Title = "User Interaction", ImageUrl = "images/userinteraction.png" });
                this.Insert(new IssueType() { Title = "Debugging", ImageUrl = "images/debugging.png" });
                this.Insert(new IssueType() { Title = "Help Files", ImageUrl = "images/helpfiles.png" });
            }
        }
    }
}
